package com.nb.result;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result<T> {
    //状态码
    private int code;
    //错误信息
    private String msg;
    //返回的数据
    private T data;
    //动态更新信息  hashmap
    private Map map = new HashMap();
    //静态成功方法
    public static <T> Result<T> success(T object){
        //返回结果封装对象
        Result<T> result = new Result<T>();
        //数据
        result.data = object;
        //成功状态码
        result.code = 1;
        //返回结果对象
        return result;
    }
    //静态错误方法
    public static <T> Result<T> error(String msg){
        Result result = new Result();
        //错误信息
        result.msg = msg;
        //错误状态码
        result.code = 0;
        return result;
    }
    //操作动态数据
    public  Result<T> add(String key,Object value){
        this.map.put(key, value);
        return this;
    }









}
